package net.qhzw.vip.qiyu.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import net.qhzw.vip.qiyu.dto.ShopAccountQuery;
import net.qhzw.vip.qiyu.entity.ShopAccount;
import net.qhzw.vip.qiyu.result.JsonResult;
import net.qhzw.vip.qiyu.service.AdminUserService;
import net.qhzw.vip.qiyu.service.ShopAccountService;
import net.qhzw.vip.qiyu.util.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/shop/account")
@Api(tags = "交易明细")
public class ShopAccountController {

    @Autowired
    private ShopAccountService shopAccountService;


    @Autowired
    private AdminUserService adminUserService;

    @GetMapping("/page")
    public JsonResult<IPage<ShopAccount>> page(Page page, ShopAccountQuery query) {
        //Long shopId = SecurityUtils.getLoginUser().getShopId();
        Long shopId =  adminUserService.getLoginUser(SecurityUtils.getUserId()).getShopId();
        query.setShopId(shopId);
        IPage<ShopAccount> pageInfo = shopAccountService.findByPage(page, query);
        return JsonResult.ok(pageInfo);
    }

}
